/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package view;

import ui.Padding;
import ui.Style;

/**
 *
 * @author tho.hoang
 */
public class StyleManager {

    public static final int STYLE_PURPLE = 1;
    public static final int STYLE_ORANGE = 2;
    public static final int STYLE_GREEN = 3;
    private int style = 0;
    private Style headerStyle, footerStyle, bodyStyle;
    private Style iconStyle, titleStyle, itemStyle;
    private Style detailStyle, textStyle, valueStyle;
    private Style gaugeStyle, textBoxStyle, buttonStyle;
    private Style cellHeadStyle, cellBodyStyle, cellFootStyle;
    private Style gridMenuStyle, listMenuStyle;
    private int headerBgColor = -1, footerBgColor = -1;
    private int bodyBgColor = -1, bodySelectedBgColor = -1;
    private int textBoxBgColor = -1, textBoxBorderColor = -1, buttonBgColor = -1;

    public StyleManager(int style) {
        initStyle(style);
    }

    private void initStyle(int style) {
        this.style = style;

        this.headerStyle = new Style(new Padding(3));
        this.iconStyle = new Style(new Padding(2, 2, 2, 2));
        this.titleStyle = new Style(new Padding(2, 2, 2, 0));
        this.bodyStyle = new Style(new Padding(1, 2, 1, 2));
        this.itemStyle = new Style(new Padding(6, 3, 6, 3));
        itemStyle.setRowHeight(2);
        this.detailStyle = new Style(new Padding(3, 3, 3, 3));
        detailStyle.setRowHeight(2);
        this.textStyle = new Style(new Padding(0, 0, 3, 0));
        textStyle.setRowHeight(2);
        this.valueStyle = new Style(new Padding(0, 0, 0, 0));
        valueStyle.setRowHeight(2);
        this.footerStyle = new Style(new Padding(3));
        this.gaugeStyle = new Style(new Padding(4));
        this.textBoxStyle = new Style(new Padding(4));
        this.buttonStyle = new Style(new Padding(4, 6, 4, 6));
        this.cellHeadStyle = new Style(new Padding(2, 4, 2, 4));
        this.cellBodyStyle = new Style(new Padding(2, 4, 2, 4));
        this.cellFootStyle = new Style(new Padding(2, 4, 2, 4));
        cellFootStyle.setRowHeight(1);
        this.gridMenuStyle = new Style(new Padding(3, 3, 3, 3));
        this.listMenuStyle = new Style(new Padding(2, 2, 2, 2));

        switch (style) {
            case STYLE_PURPLE:
                headerBgColor = 0xcc55aa;
                footerBgColor = 0xdb88c3;
                bodyBgColor = 0xfffee2;
                bodySelectedBgColor = 0xf2d4e9;
                textBoxBgColor = 0xffffff;
                textBoxBorderColor = 0xbbbbbb;
                buttonBgColor = 0xd1d1d1;
                break;
                
            case STYLE_ORANGE:
                headerBgColor = 0xfa9034;
                footerBgColor = 0xfcc18e;
                bodyBgColor = 0xfffee2;
                bodySelectedBgColor = 0xfde0c7;
                textBoxBgColor = 0xffffff;
                textBoxBorderColor = 0xbbbbbb;
                buttonBgColor = 0xd1d1d1;
                break;
                
            case STYLE_GREEN:
                headerBgColor = 0x88bb55;
                footerBgColor = 0xc3ddaa;
                bodyBgColor = 0xfffee2;
                bodySelectedBgColor = 0xdbeacc;
                textBoxBgColor = 0xffffff;
                textBoxBorderColor = 0xbbbbbb;
                buttonBgColor = 0xd1d1d1;
                break;
        }

        // header
        headerStyle.setBgColor(headerBgColor);
        // body
        bodyStyle.setBgColor(bodyBgColor);
        bodyStyle.setSelectedBgColor(bodySelectedBgColor);
        // item
        itemStyle.setBgColor(bodyBgColor);
        itemStyle.setSelectedBgColor(bodySelectedBgColor);
        // detail
        detailStyle.setBgColor(bodyBgColor);
        detailStyle.setSelectedBgColor(bodySelectedBgColor);
        // text
        textStyle.setBgColor(bodyBgColor);
        textStyle.setSelectedBgColor(bodySelectedBgColor);
        // value
        valueStyle.setBgColor(bodyBgColor);
        valueStyle.setSelectedBgColor(bodySelectedBgColor);
        // footer
        footerStyle.setBgColor(footerBgColor);
        // gauge
        gaugeStyle.setBgColor(bodyBgColor);
        gaugeStyle.setSelectedBgColor(bodySelectedBgColor);
        gaugeStyle.setBorderColor(footerBgColor);
        // text box
        textBoxStyle.setBgColor(textBoxBgColor);
        textBoxStyle.setSelectedBgColor(textBoxBgColor);
        textBoxStyle.setBorderColor(textBoxBorderColor);
        textBoxStyle.setSelectedBorderColor(footerBgColor);
        // button
        buttonStyle.setBgColor(buttonBgColor);
        buttonStyle.setSelectedBgColor(headerBgColor);
        buttonStyle.setBorderColor(textBoxBorderColor);
        buttonStyle.setSelectedBorderColor(footerBgColor);
        // table
        cellHeadStyle.setBgColor(buttonBgColor);//button
        cellHeadStyle.setBorderColor(headerBgColor);//header
        cellHeadStyle.setSelectedBorderColor(headerBgColor);//header
        cellHeadStyle.setSelectedBgColor(bodySelectedBgColor);//footer
        cellBodyStyle.setSelectedBgColor(footerBgColor);//footer
        // grid
        gridMenuStyle.setBgColor(bodyBgColor);
        gridMenuStyle.setSelectedBgColor(bodySelectedBgColor);//item
        gridMenuStyle.setBorderColor(footerBgColor);
        gridMenuStyle.setSelectedBorderColor(headerBgColor);//header
    }

    public int getStyle() {
        return style;
    }

    public void setStyle(int style) {
        initStyle(style);
    }

    public Style getHeaderStyle() {
        return headerStyle;
    }

    public Style getFooterStyle() {
        return footerStyle;
    }

    public Style getBodyStyle() {
        return bodyStyle;
    }

    public Style getIconStyle() {
        return iconStyle;
    }

    public Style getTitleStyle() {
        return titleStyle;
    }

    public Style getItemStyle() {
        return itemStyle;
    }

    public Style getTextStyle() {
        return textStyle;
    }

    public Style getValueStyle() {
        return valueStyle;
    }

    public Style getDetailStyle() {
        return detailStyle;
    }

    public Style getGaugeStyle() {
        return gaugeStyle;
    }

    public Style getTextBoxStyle() {
        return textBoxStyle;
    }

    public Style getButtonStyle() {
        return buttonStyle;
    }

    public Style getCellBodyStyle() {
        return cellBodyStyle;
    }

    public Style getCellFootStyle() {
        return cellFootStyle;
    }

    public Style getCellHeadStyle() {
        return cellHeadStyle;
    }

    public Style getGridMenuStyle() {
        return gridMenuStyle;
    }

    public void setGridMenuStyle(Style gridMenuStyle) {
        this.gridMenuStyle = gridMenuStyle;
    }

    public Style getListMenuStyle() {
        return listMenuStyle;
    }

    public void setListMenuStyle(Style listMenuStyle) {
        this.listMenuStyle = listMenuStyle;
    }
}
